SELECT
<#assign prefixName=' '>
<#if (select__beginDate??)>
${prefixName} T.BEGIN_DATE AS beginDate
	<#assign prefixName=','>
</#if>
<#if (select__endDate??)>
${prefixName} T.END_DATE AS endDate
	<#assign prefixName=','>
</#if>
<#if (select__entityCode??)>
${prefixName} T.ENTITY_CODE AS entityCode
	<#assign prefixName=','>
</#if>
<#if (select__entityId??)>
${prefixName} T.ENTITY_ID AS entityId
	<#assign prefixName=','>
</#if>
<#if (select__entityName??)>
${prefixName} T.ENTITY_NAME AS entityName
	<#assign prefixName=','>
</#if>
<#if (select__entityParentCode??)>
${prefixName} T.ENTITY_PARENT_CODE AS entityParentCode
	<#assign prefixName=','>
</#if>
<#if (select__entityParentId??)>
${prefixName} T.ENTITY_PARENT_ID AS entityParentId
	<#assign prefixName=','>
</#if>
<#if (select__entityParentName??)>
${prefixName} T.ENTITY_PARENT_NAME AS entityParentName
	<#assign prefixName=','>
</#if>
<#if (select__id??)>
${prefixName} T.ID AS id
	<#assign prefixName=','>
</#if>
<#if (select__treeCode??)>
${prefixName} T.TREE_CODE AS treeCode
	<#assign prefixName=','>
</#if>
<#if (select__treeId??)>
${prefixName} T.TREE_ID AS treeId
	<#assign prefixName=','>
</#if>
<#if (select__treeName??)>
${prefixName} T.TREE_NAME AS treeName
	<#assign prefixName=','>
</#if>
<#if (select__typeId??)>
${prefixName} T.TYPE_ID AS typeId
	<#assign prefixName=','>
</#if>
<#if prefixName == ' '>
  T.BEGIN_DATE AS beginDate
, T.END_DATE AS endDate
, T.ENTITY_CODE AS entityCode
, T.ENTITY_ID AS entityId
, T.ENTITY_NAME AS entityName
, T.ENTITY_PARENT_CODE AS entityParentCode
, T.ENTITY_PARENT_ID AS entityParentId
, T.ENTITY_PARENT_NAME AS entityParentName
, T.ID AS id
, T.TREE_CODE AS treeCode
, T.TREE_ID AS treeId
, T.TREE_NAME AS treeName
, T.TYPE_ID AS typeId
</#if>
FROM C1_ENTITY_TREE T
<#include "whereByCode.ftl">
<#assign prefixName='ORDER BY'>
<#if (order__by__beginDate??)>
${prefixName} T.BEGIN_DATE ${order__by__beginDate__value!}
	<#assign prefixName=','>
</#if>
<#if (order__by__endDate??)>
${prefixName} T.END_DATE ${order__by__endDate__value!}
	<#assign prefixName=','>
</#if>
<#if (order__by__entityCode??)>
${prefixName} T.ENTITY_CODE ${order__by__entityCode__value!}
	<#assign prefixName=','>
</#if>
<#if (order__by__entityId??)>
${prefixName} T.ENTITY_ID ${order__by__entityId__value!}
	<#assign prefixName=','>
</#if>
<#if (order__by__entityName??)>
${prefixName} T.ENTITY_NAME ${order__by__entityName__value!}
	<#assign prefixName=','>
</#if>
<#if (order__by__entityParentCode??)>
${prefixName} T.ENTITY_PARENT_CODE ${order__by__entityParentCode__value!}
	<#assign prefixName=','>
</#if>
<#if (order__by__entityParentId??)>
${prefixName} T.ENTITY_PARENT_ID ${order__by__entityParentId__value!}
	<#assign prefixName=','>
</#if>
<#if (order__by__entityParentName??)>
${prefixName} T.ENTITY_PARENT_NAME ${order__by__entityParentName__value!}
	<#assign prefixName=','>
</#if>
<#if (order__by__id??)>
${prefixName} T.ID ${order__by__id__value!}
	<#assign prefixName=','>
</#if>
<#if (order__by__treeCode??)>
${prefixName} T.TREE_CODE ${order__by__treeCode__value!}
	<#assign prefixName=','>
</#if>
<#if (order__by__treeId??)>
${prefixName} T.TREE_ID ${order__by__treeId__value!}
	<#assign prefixName=','>
</#if>
<#if (order__by__treeName??)>
${prefixName} T.TREE_NAME ${order__by__treeName__value!}
	<#assign prefixName=','>
</#if>
<#if (order__by__typeId??)>
${prefixName} T.TYPE_ID ${order__by__typeId__value!}
	<#assign prefixName=','>
</#if>
